import { createRouter, createWebHashHistory } from "vue-router";
import Login from "../views/Login.vue";
import Citizen from "../views/Citizen";
import CitizenIndex from "../views/CitizenIndex";
import CitizenLand from "../views/CitizenLand";
import CitizenForum from "../views/CitizenForum";
import Farmer from "../views/Farmer";
import FarmerIndex from "../views/FarmerIndex";
import FarmerLand from "../views/FarmerLand";
import FarmerShop from "../views/FarmerShop";
import FarmerFertilizer from "../views/FarmerFertilizer";
import FarmerOther from "../views/FarmerOther";
import Processing from "../views/Processing";
import ProcessingIndex from "../views/ProcessingIndex";
import Storage from "../views/Storage";
import StorageIndex from "../views/StorageIndex";
import Transportation from "../views/Transportation";
import TransportationIndex from "../views/TransportationIndex";

const routes = [
  {
    path: "/",
    name: "home",
    component: Login,
  },
  {
    path: "/citizen",
    name: "citizen",
    component: Citizen,
    children: [
      {
        path: "index",
        component: CitizenIndex,
      },
      {
        path: "land",
        component: CitizenLand,
      },
      {
        path: "forum",
        component: CitizenForum,
      },
    ],
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    //这段代码用于路由懒加载
    // component: () =>
    //   import(/* webpackChunkName: "about" */ "../views/AboutView.vue"),
  },
  {
    path: "/farmer",
    name: "farmer",
    component: Farmer,
    children: [
      {
        path: "index",
        component: FarmerIndex,
      },
      {
        path: "land",
        component: FarmerLand,
      },
      {
        path: "shop",
        component: FarmerShop,
        children: [
          {
            path: "fertilizer",
            component: FarmerFertilizer,
          },
          {
            path: "other",
            component: FarmerOther,
          },
        ],
      },
    ],
  },
  {
    path: "/processing",
    component: Processing,
    children: [
      {
        path: "index",
        component: ProcessingIndex,
      },
    ],
  },
  {
    path: "/storage",
    component: Storage,
    children: [
      {
        path: "index",
        component: StorageIndex,
      },
    ],
  },
  {
    path: "/transportation",
    component: Transportation,
    children: [
      {
        path: "index",
        component: TransportationIndex,
      },
    ],
  },
];

const router = createRouter({
  history: createWebHashHistory(),
  routes,
});

export default router;
